$server = 'http://localhost:8080/';

window.onload = function(){
	$orderNo = GetQueryString('orderNo');
	$.ajax({
		url: $server+'order/detail.do',
		data: {orderNo: $orderNo},
		type: "POST",
		datatype: 'json',		
		crossDomain:true, //设置跨域为true
		xhrFields:{
			withCredentials: true // 携带跨域cookie
		},
		success: function(result){
			console.log(result);
			if (result.code == 200){
				$('#orderNo')[0].innerHTML = result.data.orderNo;
				// 订单创建时间
				if (result.data.createTime != undefined && result.data.createTime != null){
					$('.orderCreate')[0].innerHTML = result.data.createTime;
				}
				// 发货时间
				if (result.data.sendTime != undefined && result.data.sendTime != null){
					$('.orderSend')[0].innerHTML = result.data.sendTime;
				}
				// 收货人姓名
				$('.receiveName')[0].innerHTML = result.data.shippingVo.receiverName;
				// 收货地址
				$('.receiveAddr')[0].innerHTML = result.data.shippingVo.receiverCity+result.data.shippingVo.receiverDistrict+result.data.shippingVo.receiverAddress;
				// 手机号码
				$('.receivePhone')[0].innerHTML = result.data.shippingVo.receiverMobile;
				// 支付时间
				if (result.data.paymentTime != undefined && result.data.paymentTime != null){
					$('.payTime')[0].innerHTML = result.data.paymentTime;
				}
				// 商品总额
				$('.totalPrice')[0].innerHTML = result.data.payment;
				// 应付
				$('.Should_pay')[0].innerHTML = result.data.payment;
				// 商品总额
				$('.totalPrice2')[0].innerHTML = result.data.payment;
				// 应付
				$('.Should_pay2')[0].innerHTML = result.data.payment;
				
				$htmlstr = '';
				// 订单项
				$.each(result.data.orderItemVoList, function(index, value){
					$htmlstr += '<li>' +
					     '<div>' +
					         '<img src="img/wangwang.jpg" alt="">' +
					         '<p>'+value.commodityName+'</p>' +
					     '</div>' +
					     '<div>' +
					         '<p>'+value.commodityId+'</p>' +
					     '</div>' +
					     '<div>' +
					         '<p>¥'+value.commodityPrice+'</p>' +
					     '</div>' +
					     '<div>' +
					         '<p>'+value.quantity+'</p>' +
					     '</div>' +
					     '<div></div>' +
					 '</li>';
				});
				$('.user_ShopResult')[0].innerHTML = $htmlstr;
			}else{
				alert(result.msg);
			}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			alert(textStatus);
		}
	});
}


// 从地址栏获取参数
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = decodeURI(window.location.search.substr(1)).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}